#include "changestatus.h"
#include "connect.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <pgsql/libpq-fe.h>
bool changestatus(char *time){
    extern PGconn *conn;
	if(!conn) conn = dbconnect();
	char command[2048];
	sprintf(command, "update messages SET status = false where status=TRUE and date <= '%s';", time);
	PGresult *res;
	res = PQexec(conn, command);
	if(PQresultStatus(res) != PGRES_COMMAND_OK){
		fprintf(stderr, "更新失败失败!\n");
		PQclear(res);
		return false;
	}
	printf("更新成功\n");
	return true;
}
